Developer Documentation

QuickTime 4 API Documentation

QuickTime For Windows Programmers

| Previous | Chapter Contents | Chapter Top | Roadmap | Next |

Graphics Ports

Because of its Mac OS origins, QuickTime uses the QuickDraw graphics routines--the Macintosh counterpart to the Windows Graphics Device Interface, or GDI--to draw to the screen. Even when running under Windows, the QuickTime Media Layer compatibility interface allows the QuickTime routines to use QuickDraw calls internally for their drawing operations. So in order to use QuickTime properly, you have to understand a little about QuickDraw.

The fundamental QuickDraw data structure is the graphics port (analogous to a Windows device context). This is a complete drawing environment that specifies all of the parameters needed to control QuickDraw's drawing operations. The port includes such things as the size and location of the line-drawing pen; colors and patterns (like brushes in Windows) for drawing, area fill, and background; the font, size, and style for text display; clipping boundaries; and so forth. All of this information is held in a data structure of type CGrafPort , pointed to by a pointer of type CGrafPtr . See Mac OS For QuickTime Programmers for a complete description of this data structure and its contents.

The C in CGrafPort and CGrafPtr stands for "color," to distinguish these from the "classic" black-and-white versions of these structures ( GrafPort and GrafPtr ), which are now obsolete. Any QTML routine that nominally expects a GrafPort or GrafPtr will accept a CGrafPort or CGrafPtr instead.

The main purpose of a graphics port is to serve as the environment in which to perform QuickDraw graphics operations. Unlike the Windows GDI routines, which always accept a device context as an explicit parameter, most QTML QuickDraw routines operate implicitly on the current port. At any given time, exactly one graphics port is current. The QTML routine GetPort

void
    GetPort
        (GrafPtr *port)

returns a pointer to the current port, and MacSetPort

void
    MacSetPort
        (GrafPtr port)

changes it.

The original Mac OS name of this routine, SetPort , conflicts with an existing name in the Windows API and had to be changed to MacSetPort . See Redefined API Names for a complete list of such name conflicts.

As we'll see, graphics ports are intimately associated with windows on the screen; the current port for QuickDraw drawing operations is typically a window. When running in the Windows environment, you have to associate a Mac OS-style graphics port with your movie window for the QuickTime routines to use in displaying a movie. We'll see how to do this in the next section.


© 1998 Apple Computer, Inc.

| Previous | Chapter Contents | Chapter Top | Roadmap | Next |